<template>
  <d-scroll-view  @refresherrefresh="getDetail" :refresher-triggered="triggered">
    <proj-detail-layout ref="projDetailLayout" :process-instance-id="processInstanceId" :project-number="projectNumber">
    <d-forms label-width="200rpx">
      <d-forms-item label="申请人">
        <pm-user-select disabled :user-id="form.changeApplicant"></pm-user-select>
      </d-forms-item>
      <d-forms-item label="申请时间" :type="DFormInputType.DATE" :input="form.changeApplicationTime"></d-forms-item>
      <d-forms-item label="变更编号" :input="form.changeNumber"></d-forms-item>
      <d-forms-item label="变更类型" :type="DFormInputType.DICT" :input="form.changeType" :dict-type="PM_DICT_TYPE.CHANGE_CATEGORY"></d-forms-item>
      <d-forms-item label="设备(系统)名称" :input="form.changeEquipment"></d-forms-item>
      <d-forms-item label="规格型号(版本号)" :input="form.specificationsModels"></d-forms-item>
      <d-forms-item label="变更原因" :input="form.changeReason"></d-forms-item>
      <view>
        <view class="form-title-1">变更内容</view>
        <view>
          <d-card>
            <view class="form-title-2">对目前业务影响</view>
            <d-forms-item disabled :input="form.businessImpact"></d-forms-item>
          </d-card>
        </view>
        <view style="margin-top: 20rpx">
          <d-card>
            <view class="form-title-2">对应用系统影响</view>
            <d-forms-item disabled :input="form.systemInfluence"></d-forms-item>
          </d-card>
        </view>
        <view style="margin-top: 20rpx">
          <d-card>
            <view class="form-title-2">变更前安全测试</view>
            <d-forms-item disabled :input="form.safetyTest"></d-forms-item>
          </d-card>
        </view>
        <view style="margin-top: 20rpx">
          <d-card>
            <view class="form-title-2">变更失败恢复措施</view>
            <d-forms-item disabled :input="form.recoveryMeasures"></d-forms-item>
          </d-card>
        </view>
        <view style="margin-top: 20rpx">
          <d-card>
            <view class="form-title-2">其他要求</view>
            <d-forms-item disabled :input="form.otherRequirements"></d-forms-item>
          </d-card>
        </view>
      </view>
    </d-forms>
  </proj-detail-layout>
  </d-scroll-view>
</template>

<script setup lang="ts">
import ProjDetailLayout from "@/components/ProjDetailLayout/index.vue";
import {useChangeApplyApi} from "@/api/pm/project/changeApply";
import {PM_DICT_TYPE} from "@/utils/pmDict";
import {DFormInputType} from "@/utils/enum";

defineOptions({ name: 'TencentChangeApplyDetail' })

const initForm = {
  projectNumber: null,
  changeApplicant: null,
  changeApplicationTime: null,
  changeNumber: null,
  changeType: null,
  specificationsModels: null,
  changeEquipment: null,
  changeReason: null,
  businessImpact: null,
  systemInfluence: null,
  safetyTest: null,
  recoveryMeasures: null,
  otherRequirements: null,
  approver: null,
  processInstanceId: null,
  storaged: null,
  userId: null,
  result: null,
  id: null,
  createTime: null,
  projectName: null,
  projectType: null,
};
const form = ref<ChangeApplyForm>(initForm);
const triggered = ref<boolean>(false);
function getDetail() {
  if (processInstanceId.value) {
    triggered.value = true
    useChangeApplyApi().getTencentCRByProcessInstanceId(processInstanceId.value).then(res => {
      if (res.code === 0) {
        form.value = res.data || initForm;
      }
    }).finally(() => {
      triggered.value = false;
    })
  }
}

const projectNumber = ref<string>(null);
const processInstanceId = ref<string>(null);
onLoad((query) => {
  projectNumber.value = query['project_number']
  processInstanceId.value = query['process_instance_id']
  getDetail();
})
</script>

<style scoped lang="scss">

</style>
